package com.ewancle.studiousfamilybackend;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class StudiousFamilyBackendApplication {

	public static void main(String[] args) {
		SpringApplication.run(StudiousFamilyBackendApplication.class, args);
	}

	/*@Bean
	public RSocketServiceProxyFactory getRSocketServiceProxyFactory(RSocketRequester.Builder requestBuilder) {
		RSocketRequester requester = requestBuilder.tcp("localhost", 7080);
		return RSocketServiceProxyFactory.builder(requester)
				.build();
	}

	@Bean
	public HelloClient getClient(RSocketServiceProxyFactory factory) {
		return factory.createClient(HelloClient.class);
	}

	@Bean
	public ApplicationRunner runRequestResponseModel(HelloClient client) {
		return args -> {
			client.sendMessage(Mono.just("请求响应 发送数据"))
					.doOnNext(message -> {
						System.out.println("请求响应模式-收到消息 :" + message);
					})
					.subscribe();
		};
	}

	@Bean
	public ApplicationRunner runStreamModel(HelloClient client) {
		return args -> {
			client.counter()
					.doOnNext(t -> {
						System.out.println("流处理模式-收到数据 :" + t);
					})
					.subscribe();
		};
	}

	@Bean
	public ApplicationRunner runFireAndForget(HelloClient client) {
		return args -> {
			client.warning(Mono.just("即发即弃 消息发送"))
					.subscribe();
		};
	}

	@Bean
	public ApplicationRunner runChannel(HelloClient client) {
		return args -> {
			client.channel(Flux.just("双向通信-发送a", "双向通信-发送b", "双向通信-发送c", "双向通信-发送d", "双向通信-发送e"))
					.doOnNext(i -> {
						System.out.println("双向通信-接收到响应："+i);
					})
					.subscribe();
		};
	}*/
}
